<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="请输入一个数字:" v-model="info">
    <input type="button" value="猜一猜" @click="f()">
    <p v-text="result"></p>
</div>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"></script>
<script>
    let v = new Vue({
        el:"div",
        data:{
            info:"",
            result:"",
            num:parseInt(Math.random()*100)+1,
            count:0,
        },
        methods:{
            f:function (){
                console.log(v.num);
                v.count = v.count+1;
                if (isNaN(v.info)){
                    v.result = "不是一个数字";
                    return;
                }
                if (v.info>v.num){
                    v.result = "猜大了！";
                }else if (v.info<v.num){
                    v.result = "猜小了！";
                }else {
                    v.result = "恭喜你第"+v.count+"次猜对了";
                }
            }
        }
    })
</script>

</body>
</html>